
/** 弹框*/
/**
 * 通用弹框
 * id  元素唯一属性
 * options 基础配置, {}
 * buttonsIdx  索引：工具栏按钮配置(快速配置),[0,1,2,3,...]
 * buttonsFunc 事件：工具栏按钮配置(快速配置),[func1,func2,func3,..]
 */
zUtil.dialogInit = function(id,options,buttonsIdx,buttonsFunc){
    var bts = [{
        text:'保存',
        id:'z-dialog-save',//0
    },{
        text:'关闭',
        id:'z-dialog-close',//1
    },{
        text:'同步',
        id:'z-dialog-async',//2
    }];
    
    var newbts = [];
    if(buttonsIdx != null){
        for (var i=0,ln = buttonsIdx.length ;i< ln; i++) {
            var tmp = bts[buttonsIdx[i]];
            if(buttonsFunc && buttonsFunc[i]){
                tmp.handler = buttonsFunc[i];
            }
            newbts.push(tmp);
        }
    }
    
    var opts = $.extend(true,{

    },options);
    
    if('undefined' !== $.type(options.buttons)){
        newbts = $.merge(newbts ,options.buttons);
    }
    opts.buttons = newbts;
    
    return $(id).dialog(opts);
};
/**
 * 通用查询弹框
 * id  元素唯一属性
 * options 基础配置, {}
 * buttonsIdx  索引：工具栏按钮配置(快速配置),[0,1,2]
 * buttonsFunc 事件：工具栏按钮配置(快速配置),[func1,func2,func3]
 */
zUtil.queryInit = function(id,options,buttonsIdx,buttonsFunc){
    var bts = [{
        text:'查询',
        id:'z-dialog-query',//0
    },{
        text:'清空',
        id:'z-dialog-clear',//1
    },{
        text:'关闭',
        id:'z-dialog-close',//2
    }];
    
    var newbts = [];
    if(buttonsIdx != null){
        for (var i=0,ln = buttonsIdx.length ;i< ln; i++) {
            var tmp = bts[buttonsIdx[i]];
            if(buttonsFunc && buttonsFunc[i]){
                tmp.handler = buttonsFunc[i];
            }
            newbts.push(tmp);
        }
    }
    
    var opts = $.extend(true,{
        
    },options);
    
    if('undefined' !== $.type(options.buttons)){
        newbts = $.merge(newbts ,options.buttons);
    }
    opts.buttons = newbts;
    
    return $(id).dialog(opts);
};